package fx.game.demo.common;

import fx.game.demo.event.ButtonEvent;
import fx.game.demo.window.AboutWindow;
import fx.game.demo.window.ColorTableWindow;
import fx.game.demo.window.GameOverTipsWindow;
import javafx.stage.Modality;
import javafx.stage.Stage;

/**
 *
 * @author: datom
 *
 * @create: 2021/12/6 16:48
 *
 * @Deprecated 不需要重复打开的窗口
 *
 **/
public class WindowManage {

    /**
     * 主窗口
     */
    private static Stage mainWindow;

    /**
     * 颜色表
     */
    private static ColorTableWindow colorTableWindow;

    /**
     * 游戏结束提示
     */
    private static GameOverTipsWindow gameOverTips;

    /**
     * 关于
     */
    private static AboutWindow aboutWindow;

    /**
     * @Author: datom 
     * @Date: 2021/12/6 16:57
     * 
     * @Description: 获取颜色方块页面
     *
     */
    public static ColorTableWindow getColorTableWindow() {
        if(colorTableWindow == null) {
            colorTableWindow = new ColorTableWindow();
            if(mainWindow != null) {
                colorTableWindow.initOwner(mainWindow);
                colorTableWindow.initModality(Modality.APPLICATION_MODAL);
            }
        }
        return colorTableWindow;
    }

    /**
     * @Author: datom 
     * @Date: 2021/12/6 16:58
     * 
     * @Description: 获取游戏结束提示页面
     *
     */
    public static GameOverTipsWindow getGameOverTips() {
        if(gameOverTips == null) {
            gameOverTips = new GameOverTipsWindow();
            if(mainWindow != null) {
                gameOverTips.initOwner(mainWindow);
                gameOverTips.initModality(Modality.APPLICATION_MODAL);
            }
            //关闭窗口事件
            gameOverTips.showingProperty().addListener(ButtonEvent.getGameOverWindowOnCloseEvent());
        }
        return gameOverTips;
    }

    /**
     * @Author: datom
     * @Date: 2021/12/6 18:42
     *
     * @Description:
     *
     */
    public static Stage getMainWindow() {
        if(mainWindow == null) {
            mainWindow = new Stage();
        }
        return mainWindow;
    }

    /**
     * @Author: datom
     * @Date: 2021/12/6 23:54
     *
     * @Description: 关于窗口
     *
     */
    public static AboutWindow getAboutWindow() {
        if(aboutWindow == null) {
            aboutWindow = new AboutWindow();
        }
        return aboutWindow;
    }
}
